import qs from 'qs'
import http from '@/http/http'
import { uploadBaseProps } from 'element-plus'

const baseUrl = '/micro-smart-application-service/ivam/'
const loginUrl = '/config-center/'
const suanfaUrl = '/suanfa/'
const uploadUrl = '/uploadpic/'
const api = {
  getFun(url, headers) {
    return http.get(baseUrl + url, { headers })
  },
  postFun(url, headers) {
    return http.post(baseUrl + url, { headers })
  },
  getWithUrl(url, params, headers) {
    return http.get(baseUrl + url + '?' + qs.stringify(params), { headers })
  },
  postWithBody(url, params, headers) {
    return http.post(baseUrl + url, params, { headers })
  },
  getJson(url) {
    return http.get(url)
  },
  downExcel(url, params = null, headers) {
    return http.post(baseUrl + url, params, { responseType: 'blob' }, { headers })
  },

  /**
   * 登录接口
   * @param url
   * @param headers
   * @returns {*}
   */
  getLoginFun(url, headers) {
    return http.get(loginUrl + url, { headers })
  },
  getLoginWithUrl(url, params, headers) {
    return http.get(loginUrl + url + '?' + qs.stringify(params), { headers })
  },
  postLoginWithBody(url, params, headers) {
    return http.post(loginUrl + url, params, { headers })
  },
  /**
   * 算法接口
   */
  getGreenWave(url, params, headers) {
    return http.get(suanfaUrl + url + '?info=' + JSON.stringify(params), { headers })
  },
  uploadFile(url, params, headers) {
    return http.post(uploadUrl + url, params, { headers })
  }
}
export default api
